/*
 * FrasesFile.cpp
 *
 *  Created on: Oct 10, 2012
 *      Author: romina
 */

#include "FrasesFile.h"

FrasesFile::FrasesFile(string path):ArchivoDeTexto(path, R) {
	int rand = RANDCSV;
	this->aleatorio = new Random(rand);
}



RecordFrase * FrasesFile::leer_registro(){
	string linea = this->obtenerLinea();
	int id = this->aleatorio->get_valor();
	//bucketString=bucketString.substr(bucketString.find_first_of('|')+1,bucketString.length()-bucketString.find_first_of('|'));
	//bucketString.substr(sizeof(int), bucketString.length()-sizeof(int));

	string apellido = linea.substr(0, linea.find_first_of(','));
	string resto = linea.substr(apellido.length() + 1, linea.length());
	string nombre = resto.substr(0, resto.find_first_of(','));
	string frase = resto.substr(resto.find_first_of(',') + 1, resto.length());

	Palabra::remove_character('"', apellido);
	Palabra::remove_character('"', nombre);
	Palabra::remove_character('"', frase);

	RecordFrase * rec = new RecordFrase(id, apellido, nombre, frase);

	return rec;
}

FrasesFile::~FrasesFile() {

}

